package com.utils.module;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by Administrator on 2016/9/23.
 */
public class DateUtils {

    /**
     * 日期格式字符串转换成时间戳
     * @param date 字符串日期
     * @param format 如：yyyy-MM-dd HH:mm:ss
     * @return
     */
    public static String date2TimeStamp(String date_str,String format){
        try {
            SimpleDateFormat sdf = new SimpleDateFormat(format);
            Date date = sdf.parse(date_str);
            return date.getTime()+"";
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }

    public static String long2Time(String date_str,String format){
        try {
            SimpleDateFormat sdf = new SimpleDateFormat(format);
            Date date = sdf.parse(date_str);
            return date.getTime()+"";
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }

}
